<?php
        define("GRID_SOURCE", "");       
        include(GRID_SOURCE."class/gridclasses.php"); //Include the grid engine.

        session_start();
        
        $id=$_REQUEST['id'];
        $id = explode("10000001",$id);  
        
        $transaccion = $id[0];
        $secuencia   = $id[1];
        
        require_once "../funciones.php";
        $link_caweb = con_caweb();
        
        $grid_id = array("grid");
        unset($_SESSION["grid"]);
        include(GRID_SOURCE."class/gridcreate.php"); //Creates grid objects.
?>
<html>
        <head>
                <title>Despiece</title>
                <script language="Javascript" type="text/javascript" src="<?php print(GRID_SOURCE);?>javascript/javascript.js"></script>
                <link href="<?php print(GRID_SOURCE);?>css/style.css" rel="stylesheet" type="text/css" />
				<script type='text/javascript' src="<?php print(GRID_SOURCE);?>server.php?client=all"></script>
				<script>
				HTML_AJAX.defaultServerUrl = '<?php print(GRID_SOURCE);?>server.php';
				</script>
                <script src="jquery.js"></script>
        </head>
        <body>
	
        <?
        $result1 ="SELECT * FROM temporal_oc WHERE transaccion='$transaccion' AND secuencia='$secuencia' ";
        $result1=mysql_query($result1,$link_caweb) or die('Error temporal_oc, '.mysql_error());
        $row1 = mysql_fetch_array($result1);
        ?>
        <font size="4">Despiece del Item: <? echo $row1[item]; ?> </font>
        <br />
    
    <form name="despiece" method="POST" action="despiece2.php">
        <?
        $result2 ="SELECT clase,descripcionclase FROM taxonomia WHERE clase='P' GROUP BY clase";
        $result2=mysql_query($result2,$link_caweb) or die('Error taxonomia, '.mysql_error());
        ?>
        <table border='0'><tr><td>
        <td>Clase:  <select name="lectura1" id="lectura1" size="1" onchange="
        $('#guardar').attr('disabled','');
        $('#layer0_subclases_compras').load('layer0_subclases_compras.php',{q:this.value});
        ">
        <option value='XXX' SELECTED>Seleccionar..</option>
        <?php
            while($row2 = mysql_fetch_array($result2))
            {
        ?>
                <option value="<? echo $row2["clase"]; ?>"><? echo $row2["descripcionclase"]; ?> </option>
        <?php
        }
        echo "</select></tr>";
        ?>        
        <td><div id="layer0_subclases_compras"></div></td>
        <td><div id="layer0_familias_compras"></div></td>
        <td><div id="layer0_grupos_compras"></div></td>
        <td>Valor :<input type="text" id="valor" size="10" name="valor" value="" /></td>
        <td><input type="hidden" name="codigosubclase" id="codigosubclase" />
        <input type="hidden" name="transaccion" id="transaccion" value="<? echo $transaccion; ?>" />
        <input type="hidden" name="secuencia" id="secuencia"  value="<? echo $secuencia; ?>" />
        <input type="hidden" name="item" id="item"  value="<? echo $row1[item]; ?>" />
        <input name="guardar" id="guardar" type="submit" value="Adicionar" disabled="disabled"/></td>
        </tr></table>
    </form>
    
        <?php
            $condicion="transaccion='$transaccion' AND secuencia='$secuencia' ";
   			$_SESSION["grid"]->SetDatabaseConnection($_SESSION['caweb']['basededatos'], "caweb", "caweb");
           	$_SESSION["grid"]->SetSqlSelect('id, transaccion,secuencia,item,item2,valor,alias,marca,modelo', 'temporal2_oc',$condicion);
			$_SESSION["grid"]->SetUniqueDatabaseColumn("id", false);
			$_SESSION["grid"]->SetTitleName(" Transaccion: $transaccion - Secuencia: $secuencia");
			$_SESSION["grid"]->SetEditModeEdit(true);
            $_SESSION["grid"]->SetEditModeDelete(true);
			$_SESSION["grid"]->SetMaxRowsEachPage(12);
            $_SESSION["grid"]->SetDatabaseColumnEditable("id", false);
			$_SESSION["grid"]->SetDatabaseColumnEditable("transaccion", false);
   	        $_SESSION["grid"]->SetDatabaseColumnEditable("secuencia", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("item", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("item2", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("valor", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("alias", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("marca", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("modelo", true);
			$_SESSION["grid"]->SetShowExcelIco(false);
			$_SESSION["grid"]->SetShowPrintIco(true);
			$_SESSION["grid"]->PrintGrid(MODE_EDIT);
        ?>
        <center><input type="button" value="Terminar Despiece" onclick="window.close();"/></center>
        </body> 
</html>